var TABLETOOLS = {
	init:false,
	createTable:function(data,innerId,scrollXInner,leftWidth,numberList,tableId){
		//创建表格
		var table = $("<table>").attr({width:"100%",cellpadding:0,cellspacing:0,border:0,id:tableId}).addClass("display");
		//创建标题
		var thead = $("<thead>").addClass("bg_green");
		var thead_tr = $("<tr>");
		$.each(data.title,function(i,item){
			var td_class = "txtc_c";
			if($.inArray(i,numberList) != -1)
				td_class = "txtc_r";
			var thead_tr_th = $("<th>").addClass(td_class).append($.trim(item));
			thead_tr.append(thead_tr_th);
		});
		thead.append(thead_tr);
		//创建表身
		var tbody = $("<tbody>");
		var size=$(innerId).parent().parent().data("highChartNum");
		$.each(data.rows,function(i,row){
			if(i+1>size && size!=0)
				return false;
			var tbody_tr = $("<tr class='gradeX'>");
			var length=row.length;
				for(var j=0;j<length;j++){
					var td_class = "txtc_c";
					if($.inArray(j,numberList) != -1)
						td_class = "txtc_r";
				 	var label = row[j];
			  		var tbody_tr_td = $("<td>").addClass(td_class).append($.trim(label));
			  		tbody_tr.append(tbody_tr_td);
		  		}
		  		tbody.append(tbody_tr);
		});
		table.append(thead).append(tbody);
		$(innerId).append(table);
	},
	formatTable:function(innerId,scrollXInner,leftWidth,tableId){
		this.oTable = $("#"+tableId).dataTable( 
		{
			"sScrollY": $(innerId).height()+"px",
			"sScrollX": "100%",
			"sScrollXInner": scrollXInner,
			"bScrollCollapse": false,
			"bPaginate": false,
	        "bFilter": false,
	        "sDom": '<"top">rt<"bottom"flp><"clear">',
			"bSort" : false
		} );
		var ofc = new FixedColumns( this.oTable ,{
			'iLeftWidth':leftWidth
		});
		this.verticalResize();
		$(window).bind('resize', function () {
			TABLETOOLS.oTable.fnAdjustColumnSizing();
		});
	},
	verticalResize:function(){
		var that = this;
		var height = 0;
		if(!$("div.top_menu.bg_gray").is(":hidden")){
			height = $("div.top_menu.bg_gray").outerHeight(true);
		}
		$('div.dataTables_scrollBody,div.DTFC_LeftBodyWrapper,div.DTFC_LeftWrapper,div.DTFC_ScrollWrapper').height(
			$('#content2').height()-$("div>.dataTables_scrollHead").height()-height
		);
		if($('div.dataTables_scroll').length!=0)
			$('div.dataTables_scroll').width($('div.DTFC_ScrollWrapper').width()-$('div.dataTables_scroll').offset().left);
		if(!this.init){
			$(window).bind('resize', function () {
				that.verticalResize();
			});
			this.init = true;
		}
	}
};

